473,419 Members | 3,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Programatically click a web page button

Using C# and a web browser control, is there a way to programatically click a
web page button?
Dec 15 '05 #1
3 15580
KH
No, C# runs on the server, a button click occurs on the client. Try some
javascript.

..NET DLLs can be hosted as objects (like Java applets) in IE, but I don't
think that's what you're talking about.
"Pete" wrote:
Using C# and a web browser control, is there a way to programatically click a
web page button?

Dec 15 '05 #2
Pete,
Yes, assuming you have navigated the webBrowser control to the requested
page, and then obtained an DOM reference to the page model, you can use DOM
methods to call the submit method on the submit button of a form control, for
example.

But the real question is what do you *really* want to do? If this button
submits a form, you don't even need a webbrowser control for that. You can
simply construct a POST WebRequest with the correct multipart enctype and
send it out.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Pete" wrote:
Using C# and a web browser control, is there a way to programatically click a
web page button?

Dec 15 '05 #3
Thanks for the response. I will look at how to use the DOM reference as you
suggested. I did try it but didn't get too far and had wondered if there was
an easier way.

What I really want to do:

Basically, a windows form program that can aceess secure sites (that I have
valid access to) and mine some data.
I wanted to use HttpWebRequest/Response but couldn't figure out how to use
for https: sites.
Most sites want userid/password, some want userid/pword/pin.
I haven't been able to find a guide to show me how to handle logon info,
site redirection, cookies, etc (at least not that I could follow well enoguh
to get to work).
So, I thought the easiest way to accomplish would be to fill in login data
on the form using HtmlElement, and then submit the form by clicking the
button.

Filling in the form was easy, clicking the button not so easy.

If you have any good (hopefully relatively easy to follow) reference on how
to do this more efficiently, that would be great.

Thanks again,
Pete

"Peter Bromberg [C# MVP]" wrote:
Pete,
Yes, assuming you have navigated the webBrowser control to the requested
page, and then obtained an DOM reference to the page model, you can use DOM
methods to call the submit method on the submit button of a form control, for
example.

But the real question is what do you *really* want to do? If this button
submits a form, you don't even need a webbrowser control for that. You can
simply construct a POST WebRequest with the correct multipart enctype and
send it out.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Pete" wrote:
Using C# and a web browser control, is there a way to programatically click a
web page button?

Dec 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Csaba2000 | last post by:
I want to be able to programatically click on the center of an <INPUT type=image ...> element (I only care about IE 5.5+). This should work regardless of whether IE has focus. Normally you would...
3
by: asr | last post by:
I've a form with a button on it. How to raise (I mean to run the code within the click event of the button) without clicking the button? Is it possible to raise the events programatically.
2
by: jw56578 | last post by:
if i have an Input type Image how am i suppose to programatically submit it through JS. code: <INPUT type="text" onkeyup="javascript:if(event.keyCode==13){btnClick.click();}"> <INPUT...
1
by: Carl Mercier | last post by:
Hi, I have a long form that post back to itself at different places (different controls). At the very end, I have a button called "Next" that post back to itself again causing some panels to be...
4
by: stb | last post by:
I have an empty asp:table on a form. Rows and cells in the rows are added programatically. At the end of each row, there is a cell with a button inside it. How do I catch the button's click...
11
by: Neo Geshel | last post by:
Greetings. Hopefully someone will be able to untie this Gordian Knot I have found myself bound up in. I am trying to add a submit button dynamically to a PlaceHolder. This button will help...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
0
by: OceanBreeze | last post by:
I have added a LinkButton to the web page programatically from server side code using ASP 2.0 and C# in my Page_Load method. I also associate this LinkButton with a LinkButton_ClickHandler_Edit and...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.